/*
 * @Author: wuyuxin
 * @Date: 2022-02-20 22:04:53
 * @LastEditors: wuyuxin
 * @LastEditTime: 2022-02-21 15:37:58
 * @Description: 
*/
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');

const isProduction = false
const path = require('path')
module.exports = function(env) {
  return {
    mode: "development",
      // 专门为webpack-dev-server
    // devServer为开发过程中, 开启一个本地服务
    devServer: {
      // hot: true,
      // host: "0.0.0.0",
      port: 7777,
      // open: true,
      hotOnly: true,
      compress: true,
      // publicPath: "/",
      watchContentBase: true,
      contentBase: path.resolve(__dirname, "./why"),
      proxy: {
        // "/why": "http://localhost:8888"
        "/why": {
          target: "http://localhost:8888",
          pathRewrite: {
            "^/why": ""
          },
          secure: false,
          changeOrigin: true
        }
      },
      // historyApiFallback: true,
      historyApiFallback: {
        rewrites: [
          {from: /abc/, to: "/index.html"}
        ]
      }
    },
    plugins: [
      new ReactRefreshWebpackPlugin(),
    ]
  }
}